<?php

namespace App\Models\Admin;

use Illuminate\Database\Eloquent\Model;

class Picture extends Model
{
    /*
     * @ 使用eloquent create方法能操作的 字段
     */
    protected $fillable = ['picture_user_id','picture_thumbnail','picture_category_id','picture_check','picture_status','picture_health_point','picture_likenum','picture_dislikenum','picture_rank_nuber','picture_uprank_likenum','picture_uprank_condition','picture_uprank_type'];
    /**
     * 与模型关联的数据表
     */
    protected $table = 'y_pictures';
    /**
     * 与模型关联的数据表的主键
     */
    protected $primaryKey = 'picture_id';

    public function pictures(){
        return $this->belongsTo('App\Models\Admin\User', 'picture_user_id', 'user_id');
    }

    public function rank(){
        return $this->belongsTo('App\Models\Admin\Rank', 'picture_rank_number', 'rank_number');
    }

    public function category(){
        return $this->belongsTo('App\Models\Admin\Category', 'picture_category_id', 'category_id');
    }
    /*
     * 一个修改器，修改picture_check字段的值
     */
    public function setPictureCheckAttribute($value)
    {
        $this->attributes['picture_check'] = $value;
    }
    /*
     * 一个修改器，修改picture_likenum字段的值
     */
    public function setPictureLikenumAttribute($value)
    {
        $this->attributes['picture_likenum'] = $value;
    }
    /*
     * 一个修改器，修改picture_dislikenum字段的值
     */
    public function setPictureDislikenumAttribute($value)
    {
        $this->attributes['picture_dislikenum'] = $value;
    }
    /*
     * 一个修改器，修改picture_status字段的值
     */
    public function setPictureStatusAttribute($value)
    {
        $this->attributes['picture_status'] = $value;
    }
    /*
     * 一个修改器，修改picture_health_point字段的值
     */
    public function setPictureHealthPointAttribute($value)
    {
        $this->attributes['picture_health_point'] = $value;
    }
}
